#ifndef THREADSAFEQUEUE_HPP_
#define THREADSAFEQUEUE_HPP_

#include <queue>
#include "system/thread/Mutex.hpp"

namespace KitContainer
{
	template <class T>
	class ThreadSafeQueue
	{
	public:
		void push(T iValue);
		T  pop();
		bool empty();
	private:
		std::queue<T> _q;
		SystemThread::Mutex _mutex;
	};
}

namespace KitContainer
{
	template <class T>
	void ThreadSafeQueue <T> ::push(T iNewElement)
	{
		_mutex.lock();
		{
			_q.push(iNewElement);
		}
		_mutex.unlock();
	}

	template <class T>
	bool ThreadSafeQueue<T>::empty()
	{
		bool aReturnValue;
		_mutex.lock();
		{
			aReturnValue = _q.empty();
		}
		_mutex.unlock();
		return aReturnValue;
	}

	template <class T>
	T ThreadSafeQueue<T>::pop()
	{
		T  aReturnValue;
		_mutex.lock();
		{
			aReturnValue = _q.front(); _q.pop();
		}
		_mutex.unlock();
		return aReturnValue;
	}
}


#endif /* THREADSAFEVECTOR_HPP_ */
